package com.jt.controller;

import com.jt.pojo.Emp;
import com.jt.pojo.User;
import com.jt.service.EmpService;
import com.jt.service.UserService;
import com.jt.vo.PageResult;
import com.jt.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/report")
@CrossOrigin    //前后端进行跨域操作
public class EmpController {

    @Autowired
    private EmpService empService;

    @GetMapping("/findEmp")
    public SysResult findEmp() {
        return SysResult.success(empService.findEmp());
    }

    @PostMapping("/addEmp")
    public SysResult addEmp(@RequestBody Emp emp) {
        empService.addEmp(emp);
        return SysResult.success(emp);
    }

    @PutMapping("/updateEmp")
    public SysResult updateEmp(@RequestBody Emp emp) {
        empService.updateEmp(emp);
        return SysResult.success(emp);
    }

    @DeleteMapping("/{empId}")
    public SysResult deleteEmp(@PathVariable Integer empId) {
        empService.deleteEmp(empId);
        return SysResult.success();
    }
//    @GetMapping("/list")
//    public SysResult findEmpList(PageResult pageResult){
//        pageResult = empService.findEmpList(pageResult);
//        return SysResult.success(pageResult);
//    }

//    @GetMapping("/{id}")
//    public SysResult findEmpById(@PathVariable Integer empId){
//        empService.findEmpById(empId);
//        return SysResult.success();
//    }
}
